package com.example.demo.mapper;


import com.example.demo.entity.LikeMusicComment;

import org.apache.ibatis.annotations.*;

@Mapper
public interface LikeMusicCommentMapper {

    //实现点赞
    @Insert("insert into like_musiccomment_tb (user_id,music_comment_id) values (#{user_id},#{music_comment_id})")
    int insertLikeMusicComment(LikeMusicComment likeMusicComment);


    //取消点赞
    @Delete("delete from like_musiccomment_tb where user_id=#{user_id} and music_comment_id = #{music_comment_id}")
    int deleteLikeMusicComment(@Param("user_id") Integer user_id, @Param("music_comment_id") Integer music_comment_id);


    //检查用户是否已经点赞过某条评论
    @Select("SELECT COUNT(*) FROM like_musiccomment_tb WHERE user_id = #{user_id} AND music_comment_id = #{music_comment_id}")
    int checkIfLike(@Param("user_id") Integer user_id, @Param("music_comment_id") Integer music_comment_id);

    //根据评论id统计对应评论点赞数量
    @Select("select COUNT(*) FROM like_musiccomment_tb WHERE music_comment_id= #{music_comment_id}")
    Integer countLike(@Param("music_comment_id") Integer music_comment_id);

}